import request from '@/plugins/sourcing-request'
import ftsRequest from '@/plugins/fts-request'
import { sourcingRequest } from '@api/service/sourcing'

// 报价信息 -获取报价信息 基本信息 供应商信息 商品信息 - 询价
export const getQuotationInfoService = (data) => {
  return request({
    url: 'sourceBill/queryQuoteInquiry',
    method: 'GET',
    data
  })
}

// 报价信息 -获取报价信息 基本信息 供应商信息 商品信息 -订货
export const getOrderQuotationInfoService = (data) => {
  return request({
    url: 'orderInquiry/queryQuoteOrder',
    method: 'GET',
    data
  })
}

// 报价信息-获取供应商信息
export const getSupplierInfoService = (data) => {
  return request({
    url: 'sourceSupplier/querySupplier',
    method: 'POST',
    data
  })
}

// 报价信息-增加供应商
export const addSupplierService = (data) => {
  return request({
    url: 'sourceSupplier/addSupplier',
    method: 'POST',
    data
  })
}

// 报价信息 -删除供应商
export const delSupplierService = (data) => {
  return request({
    url: 'sourceSupplier/delSupplier',
    method: 'GET',
    data
  })
}

// 报价信息 - 报价详情明细
export const getQuotationDetailService = (data) => {
  return request({
    url: 'sourceSkuQuote/querySourceSkuQuote',
    method: 'GET',
    data
  })
}

// 报价信息 - 报价详情 - 分摊运费
export const shareFreightService = (data) => {
  return request({
    url: 'sourceSkuQuote/calcCostPrice',
    method: 'POST',
    data
  })
}

// 报价信息 - 商品信息 - 获取资质
export const getQualificationService = (data) => {
  return ftsRequest({
    url: 'fileUpload/getAnnexList',
    method: 'POST',
    data
  })
}

// 报价信息 - 商品信息 - 删除资质
export const deleteQualificationService = (data) => {
  return ftsRequest({
    url: 'fileUpload/deleteFile',
    method: 'POST',
    data
  })
}

// 报价信息 - 商品信息 - 删除商品
export const delGoodsService = (data) => {
  return request({
    url: 'orderInquiry/deleteProduct',
    method: 'GET',
    data
  })
}

// 报价信息 - 商品信息 - 批量删除商品
export const delAllGoodsService = (data) => {
  return request({
    url: 'orderInquiry/batchDeleteProduct',
    method: 'POST',
    data
  })
}

// 报价信息 - 单个供应商完成报价 - 报价详情
export const addQuotationService = (data) => {
  return request({
    url: 'sourceSupplier/completeQuote',
    method: 'POST',
    data
  })
}

// 报价信息- 提交报价 - 报价完成
export const submitQuotationService = (data) => {
  return request({
    url: 'orderInquiry/quoteComplete',
    method: 'POST',
    data
  })
}

// 报价信息- 提交报价 - 暂存报价
export const temporaryQuotationService = (data) => {
  return request({
    url: 'sourceSupplier/completeQuoteSaveTemp',
    method: 'POST',
    data
  })
}
// 定标信息 -获取定标信息 - 询价
export const getInqueryCalibrationInfoService = (data, loadingFn) => sourcingRequest({
  url: 'sourceBill/queryWinBiddingInquiry',
  type: 'get',
  data,
  loadingFn,
})

// 定标信息 -获取定标信息 - 订货
export const getOrderCalibrationInfoService = (data) => {
  return request({
    url: 'orderInquiry/queryWinBiddingOrder',
    method: 'GET',
    data
  })
}

// 定标信息- 定标完成 - 第一步
export const completeCalibrationStep1Service = (data) => {
  return request({
    url: 'orderInquiry/calibrateCompleteStep1',
    method: 'POST',
    data
  })
}

// 定标信息- 定标完成 - 第二步
export const completeCalibrationStep2Service = (data) => {
  return request({
    url: 'orderInquiry/calibrateCompleteStep2',
    method: 'POST',
    data
  })
}
// 定标信息- 定标完成 - 第三步
export const completeCalibrationStep3Service = (data) => {
  return request({
    url: 'orderInquiry/calibrateCompleteStep3',
    method: 'POST',
    data
  })
}
// 定标信息- 临采商品加码 获取 orderNo
export const getOrderNoService = (data) => {
  return request({
    url: 'sourceSkuQuote/updateSkuInfo',
    method: 'GET',
    data
  })
}
// 获取发票类型、税率字典 10017 发票类型 10100 税率 10146 运费承担方
export const getSysDictByTypeService = (data) => {
  return request({
    url: 'purchaseOrder/getSysDictByType',
    method: 'POST',
    data
  })
}
// 获取发票类型、税率字典 10017 发票类型 10100 税率 10146 运费承担方
export const pushInquiryPriceService = (data) => {
  return request({
    url: 'sourceSupplier/pushScm',
    method: 'POST',
    data
  })
}
// 保存附件id
export const saveAttachmentService = (data) => {
  return request({
    url: 'sourceBill/saveFileGroupId',
    method: 'POST',
    data
  })
}
// 获取推荐供应商
export const getRecommendSupplierService = (data, loadingFn) => sourcingRequest({
  url: 'sourceSupplier/smartRecommendSupplier',
  type: 'get',
  data,
  loadingFn,
})
export const getSupplierService = (data, loadingFn) => sourcingRequest({
  url: 'sourceSupplier/querySupplier',
  type: 'POST',
  data,
  loadingFn,
})

// 批量导出供应商信息
export const batchExportSupplierService = (data, loadingFn) => sourcingRequest({
  url: 'sourceSupplier/exportSupplierAndSkuQuote',
  type: 'post',
  data,
  loadingFn,
  isExport: true
})

// 订货定标 获取定标信息
export const queryCalibrationInfoService = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/queryWinBiddingOrder',
  type: 'GET',
  data,
  loadingFn,
})

// 订货定标- 定标完成 - 第一步
export const calibrationStep1Service = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/calibrateCompleteStep1',
  type: 'POST',
  data,
  loadingFn,
})

// 订货定标- 定标完成 - 第二步
export const calibrationStep2Service = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/calibrateCompleteStep2',
  type: 'POST',
  data,
  loadingFn,
})

// 订货定标- 定标完成 - 第三步
export const calibrationStep3Service = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/calibrateCompleteStep3',
  type: 'POST',
  data,
  loadingFn,
})

// 订货定标- 线索转潜在
export const turnIntoPotentialService = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/tempToPotential',
  type: 'get',
  data,
  loadingFn,
})

// 订货定标- 完善图文信息
export const updateImgInfoService = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/maintenanceImg',
  type: 'get',
  data,
  loadingFn,
})

// 客户询价定标- 询价完成
export const completeInquiryService = (data, loadingFn) => sourcingRequest({
  url: 'winBidding/bidding',
  type: 'POST',
  data,
  loadingFn,
})

// 订货定标、询价定标- 单据下线索商品为一物多码商品的修改为主码
export const updateSkuCodeService = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/updateTwinsSkuByMainSku',
  type: 'get',
  data,
  loadingFn,
})

// 订货定标 - 驳回 重新询价
export const reinquiryService = (data, loadingFn) => sourcingRequest({
  url: 'orderInquiry/orderAfreshInquiry',
  type: 'get',
  data,
  loadingFn,
})

// 保存供应商附件ID
export const saveSupplierFileGroupIdService = (data, loadingFn) => sourcingRequest({
  url: 'sourceBill/saveSupplierFileGroupId',
  type: 'post',
  data,
  loadingFn,
})

// 关闭协同询价单
export const closeInquiryService = (data, loadingFn) => sourcingRequest({
  url: 'sourceSupplier/cancelSupplierInquiry',
  type: 'post',
  data,
  loadingFn,
})

// 计算是否厂家直送
export const computeFactoryDirectService = (data, loadingFn) => sourcingRequest({
  url: 'factoryDirectConfig/checkFactoryDirectConfig',
  type: 'post',
  data,
  loadingFn,
})
